(function () {

    angular
        .module("myApp")
        .directive("scrollBarDirective", scrollBarDirective);

    function scrollBarDirective() {
        function link($scope, element) {
            var container = element[0];
            $scope.$watch($(container), function () {
                $(container).mCustomScrollbar("destroy");
                $(container).mCustomScrollbar({
                    axis: "y",// horizontal scrollbar
                    scrollbarPosition: 'inner',
                    autoDraggerLength: false,
                    scrollInertia: 300
                });
            }, true);
        }

        return {
            restrict: 'A',
            link: link
        };
    }
}());
